package com.haredot.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.haredot.validation.Insert;
import com.haredot.validation.Update;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Swiper {

    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(groups = Update.class, message = "ID不允许为空")
    private Long id;

    @NotNull(groups = {Update.class, Insert.class}, message = "系统ID 不允许为空")
    private Long sysId;

    /**
     * 轮播图图片地址
     */
    @NotEmpty(groups = {Update.class, Insert.class}, message = "轮播图不允许为空")
    private String url;

    /**
     * 轮播图超链接地址
     */
    @NotEmpty(groups = {Update.class, Insert.class}, message = "超链接地址不允许为空")
    @URL(groups = {Update.class, Insert.class}, message = "超链接地址格式不正确")
    private String linkUrl;

    /**
     * 状态
     */
    @NotNull(groups = {Update.class, Insert.class}, message = "状态不允许为空")
    private Boolean state;

    /**
     * 录入时间
     */
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 删除标记
     */
    private Boolean del;
}